﻿<%@ Page Title="" Language="C#" MasterPageFile="~/presentation/MasterPage.Master"
    AutoEventWireup="true" CodeBehind="PokojForm.aspx.cs" Inherits="ISHotel_ASP.presentation.PokojForm" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div align="left" class="art-blockcontent-body">
        <table>
            <tr>
                <td>
                </td>
                <td align="center">
                    <asp:Label ID="LabelNovyPokoj" runat="server" Text="Nový pokoj"></asp:Label>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelIDPokoje" runat="server" Text="Číslo pokoje:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBoxIDPokoje" runat="server" MaxLength="5"></asp:TextBox>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidatorIDPokoje" runat="server" ErrorMessage="*"
                        ControlToValidate="TextBoxIDPokoje"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidatorIDPokoje2" runat="server"
                        ErrorMessage="Jen čísla!" ValidationExpression="\d+" ControlToValidate="TextBoxIDPokoje">
                    </asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelPopis" runat="server" Text="Popis pokoje:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBoxPopis" runat="server" Height="130px" TextMode="MultiLine"
                        Width="230px" MaxLength="500"></asp:TextBox>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidatorPopis" runat="server" ErrorMessage="*"
                        ControlToValidate="TextBoxPopis"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelKapacita" runat="server" Text="Kapacita:"></asp:Label>
                </td>
                <td>
                    <asp:DropDownList ID="DropDownListKapacita" runat="server" Width="140px">
                        <asp:ListItem Value="1">1 lůžkový</asp:ListItem>
                        <asp:ListItem Value="2">2 lůžkový</asp:ListItem>
                        <asp:ListItem Value="3">3 lůžkový</asp:ListItem>
                        <asp:ListItem Value="4">4 lůžkový</asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelCena" runat="server" Text="Cena za noc:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBoxCena" runat="server" MaxLength="5"></asp:TextBox>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidatorCena" runat="server" ErrorMessage="*"
                        ControlToValidate="TextBoxCena"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Jen čísla!"
                        ValidationExpression="\d+" ControlToValidate="TextBoxCena">
                    </asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td align="center">
                    <asp:Button ID="ButtonVlozPokoj" runat="server" Text="Vlož" OnClick="ButtonVlozPokoj_Click" />
                </td>
                <td>
                </td>
            </tr>
        </table>
        <asp:ObjectDataSource ID="ODS_ListPokoj" runat="server" SelectMethod="Select" TypeName="ISHotelApp.Database.PokojTable">
        </asp:ObjectDataSource>
        <br />
        <asp:Label ID="LabelErr" runat="server" Visible="True" ForeColor="Red"></asp:Label>
        <br />
        <br />
        <%--<asp:GridView ID="GridViewPokoj" runat="server" AutoGenerateColumns="False" DataSourceID="ODS_Pokoj"
            AllowPaging="True" DataKeyNames="id_pokoje">
            <Columns>
                <asp:TemplateField ShowHeader="False">
                    <ItemTemplate>
                        <asp:ImageButton ID="ImageButtonDel" runat="server" CommandArgument='<%# Eval("id_pokoje") %>'
                            CommandName="DeletePokoj" OnCommand="button_Command" ImageUrl="~/images/delete.jpg"
                            OnClientClick="javascript: return confirm(&apos;Opravdu smazat pokoj?&apos;);" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:hyperlinkfield headertext="Číslo Pokoje"
            datatextfield="id_pokoje"
            datanavigateurlformatstring="PokojDetailForm.aspx?id_pokoje={0}"
            datanavigateurlfields="id_pokoje" />
                
                <asp:BoundField DataField="popis_pokoje" HeaderText="Popis pokoje" SortExpression="popis_pokoje"
                    ItemStyle-Width="350" />
                <asp:BoundField DataField="kapacita" HeaderText="Kapacita" SortExpression="kapacita" />
                <asp:BoundField DataField="cena_pokoje" HeaderText="Cena za noc" SortExpression="cena_pokoje" />
                <asp:CommandField ShowSelectButton="True" HeaderText="Upravit" SelectImageUrl="../images/pencil.gif"
                    ButtonType="Image" ItemStyle-HorizontalAlign="Center" />
            </Columns>
        </asp:GridView>
        <asp:ObjectDataSource ID="ODS_Pokoj" runat="server" SelectMethod="Select" TypeName="ISHotel.Database.PokojTable"
            DeleteMethod="Delete">
            <DeleteParameters>
                <asp:Parameter Name="id_pokoje" Type="Int32" />
            </DeleteParameters>
        </asp:ObjectDataSource>
        <br />
        <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="300px" AutoGenerateRows="False"
            DataSourceID="ODS_PokojDetail" DataKeyNames="id_pokoje">
            <Fields>
                <asp:TemplateField HeaderText="Číslo pokoje" SortExpression="id_pokoje">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("id_pokoje") %>' ReadOnly="True"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label4" runat="server" Text='<%# Bind("id_pokoje") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Popis" SortExpression="popis_pokoje">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("popis_pokoje") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("popis_pokoje") %>' MaxLength="500"
                            TextMode="MultiLine" Height="50"></asp:TextBox>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Kapacita" SortExpression="kapacita">
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("kapacita") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownListKapacitaDetail" runat="server" Width="140px" SelectedValue='<%# Bind("kapacita") %>'>
                            <asp:ListItem Value="1">1 lůžkový</asp:ListItem>
                            <asp:ListItem Value="2">2 lůžkový</asp:ListItem>
                            <asp:ListItem Value="3">3 lůžkový</asp:ListItem>
                            <asp:ListItem Value="4">4 lůžkový</asp:ListItem>
                        </asp:DropDownList>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Cena za noc" SortExpression="cena_pokoje">
                    <ItemTemplate>
                        <asp:Label ID="Label6" runat="server" Text='<%# Bind("cena_pokoje") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("cena_pokoje") %>' MaxLength="5"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorPSCDetail" runat="server" ErrorMessage="*"
                            ControlToValidate="TextBox6" ValidationGroup="Detail"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidatorPSC3Detail" runat="server"
                            ErrorMessage="Jen čísla!" ValidationExpression="\d+" ControlToValidate="TextBox6"
                            ValidationGroup="Detail">
                        </asp:RegularExpressionValidator>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:CommandField ShowEditButton="True" CausesValidation="True" ValidationGroup="Detail" />
            </Fields>
        </asp:DetailsView>
        <asp:ObjectDataSource ID="ODS_PokojDetail" runat="server" SelectMethod="Select" UpdateMethod="Update"
            OnUpdated="PokojDetail_OnUpdated" DataObjectTypeName="ISHotel.Database.Pokoj"
            TypeName="ISHotel.Database.PokojTable">
            <SelectParameters>
                <asp:ControlParameter PropertyName="SelectedValue" Type="int32" Name="id_pokoje"
                    ControlID="GridViewPokoj"></asp:ControlParameter>
            </SelectParameters>
        </asp:ObjectDataSource>--%>
                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                DataSourceID="ODS_PokojPage" DataKeyNames="id_pokoje">
                <AlternatingRowStyle BackColor="White" />
                <Columns>
                    <asp:TemplateField ShowHeader="False">
                    <ItemTemplate>
                        <asp:ImageButton ID="ImageButtonDel" runat="server" CommandArgument='<%# Eval("id_pokoje") %>'
                            CommandName="DeletePokoj" OnCommand="button_Command" ImageUrl="~/images/delete.jpg"
                            OnClientClick="javascript: return confirm(&apos;Opravdu smazat pokoj?&apos;);" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:hyperlinkfield headertext="Číslo Pokoje"
            datatextfield="id_pokoje"
            datanavigateurlformatstring="PokojDetailForm.aspx?id_pokoje={0}"
            datanavigateurlfields="id_pokoje" />
                
                <asp:BoundField DataField="popis_pokoje" HeaderText="Popis pokoje" SortExpression="popis_pokoje"
                    ItemStyle-Width="350" />
                <asp:BoundField DataField="kapacita" HeaderText="Kapacita" SortExpression="kapacita" />
                <asp:BoundField DataField="cena_pokoje" HeaderText="Cena za noc" SortExpression="cena_pokoje" />
                <asp:CommandField ShowSelectButton="True" HeaderText="Upravit" SelectImageUrl="../images/pencil.gif"
                    ButtonType="Image" ItemStyle-HorizontalAlign="Center" />
        
                </Columns>
            </asp:GridView>


       <asp:ObjectDataSource ID="ODS_PokojPage" runat="server" SelectMethod="CreateSQLPage" TypeName="ISHotelApp.Database.PokojTable"
            DeleteMethod="Delete">

            <SelectParameters>
                    <asp:ControlParameter ControlID="LabelCurentPage" DefaultValue="2" 
                        Name="pageNo" PropertyName="Text" Type="String" />
                    <asp:ControlParameter ControlID="DropPocetZaz" DefaultValue="15" 
                        Name="pageSize" PropertyName="SelectedValue" Type="String" />
                </SelectParameters>


            <DeleteParameters>
                <asp:Parameter Name="id_pokoje" Type="Int32" />
            </DeleteParameters>
        </asp:ObjectDataSource>
        <asp:Label ID="Label7" runat="server" Font-Bold="True" Font-Size="Small" 
                Text="Stránka 1"></asp:Label>
            <asp:Button ID="ButtonMinus" runat="server" Text="&lt;&lt;" 
                onclick="ButtonMinus_Click" CausesValidation="False" />
            <asp:Label ID="LabelCurentPage" runat="server" Font-Bold="True" 
                Font-Size="Small" Text="1" Width="20px"></asp:Label>
            <asp:Button ID="ButtonPlus" runat="server" Text="&gt;&gt;" 
                onclick="ButtonPlus_Click" CausesValidation="False" />
            <asp:Label ID="LabelLast" runat="server" Font-Bold="True" Font-Size="Small" 
                Text="1" Width="25px"></asp:Label>
            <asp:TextBox ID="TextGotoPage" runat="server" Width="30px">1</asp:TextBox>
            <asp:Button ID="ButtonJdiNaStr" runat="server" Text="Jdi" 
                onclick="ButtonJdiNaStr_Click" CausesValidation="False"/>
            <asp:Label ID="Label10" runat="server" Font-Bold="True" Font-Size="Small" 
                Text="Počet:"></asp:Label>
            <asp:DropDownList ID="DropPocetZaz" runat="server" 
                onselectedindexchanged="DropPocetZaz_SelectedIndexChanged" 
                AutoPostBack="True">
                <asp:ListItem Selected="True">10</asp:ListItem>
                <asp:ListItem>15</asp:ListItem>
                <asp:ListItem>20</asp:ListItem>
            </asp:DropDownList>
            <asp:Label ID="LblStatus" runat="server" ForeColor="Red" Font-Size="Small"></asp:Label>
            <br /><br />

            <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="300px" AutoGenerateRows="False"
            DataSourceID="ODS_PokojDetail" DataKeyNames="id_pokoje">
            <Fields>
                <asp:TemplateField HeaderText="Číslo pokoje" SortExpression="id_pokoje">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("id_pokoje") %>' ReadOnly="True"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label4" runat="server" Text='<%# Bind("id_pokoje") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Popis" SortExpression="popis_pokoje">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("popis_pokoje") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("popis_pokoje") %>' MaxLength="500"
                            TextMode="MultiLine" Height="50"></asp:TextBox>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Kapacita" SortExpression="kapacita">
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("kapacita") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownListKapacitaDetail" runat="server" Width="140px" SelectedValue='<%# Bind("kapacita") %>'>
                            <asp:ListItem Value="1">1 lůžkový</asp:ListItem>
                            <asp:ListItem Value="2">2 lůžkový</asp:ListItem>
                            <asp:ListItem Value="3">3 lůžkový</asp:ListItem>
                            <asp:ListItem Value="4">4 lůžkový</asp:ListItem>
                        </asp:DropDownList>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Cena za noc" SortExpression="cena_pokoje">
                    <ItemTemplate>
                        <asp:Label ID="Label6" runat="server" Text='<%# Bind("cena_pokoje") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("cena_pokoje") %>' MaxLength="5"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorPSCDetail" runat="server" ErrorMessage="*"
                            ControlToValidate="TextBox6" ValidationGroup="Detail"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidatorPSC3Detail" runat="server"
                            ErrorMessage="Jen čísla!" ValidationExpression="\d+" ControlToValidate="TextBox6"
                            ValidationGroup="Detail">
                        </asp:RegularExpressionValidator>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:CommandField ShowEditButton="True" CausesValidation="True" ValidationGroup="Detail" />
            </Fields>
        </asp:DetailsView>
        <asp:ObjectDataSource ID="ODS_PokojDetail" runat="server" SelectMethod="Select" UpdateMethod="Update2"
            OnUpdated="PokojDetail_OnUpdated" DataObjectTypeName="ISHotelApp.Database.Pokoj"
            TypeName="ISHotelApp.Database.PokojTable">
            <SelectParameters>
                <asp:ControlParameter PropertyName="SelectedValue" Type="int32" Name="id_pokoje"
                    ControlID="GridView1"></asp:ControlParameter>
            </SelectParameters>
        </asp:ObjectDataSource>

    </div>
</asp:Content>
